package com.retail.setting.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.setting.entity.request.RetailFxLevelRequest;
import com.retail.setting.entity.vo.RetailFxLevelVo;
import com.retail.setting.service.RetailFxLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 分销等级设置 API
* @author Administrator
*/
@Api(tags = "分销等级设置 API")
@RestController
@RequestMapping("/retailFxLevel")
public class RetailFxLevelController extends AbstractCommonController<RetailFxLevelService, RetailFxLevelRequest, RetailFxLevelVo>{

    private final RetailFxLevelService retailFxLevelService;

    public RetailFxLevelController(RetailFxLevelService retailFxLevelService) {
        this.retailFxLevelService = retailFxLevelService;
    }

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(retailFxLevelService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存分销等级设置")
    public Result<Integer> save(@RequestBody RetailFxLevelRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(retailFxLevelService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新分销等级设置")
    public Result<Integer> update(@RequestBody RetailFxLevelRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(retailFxLevelService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("分销等级设置-查询")
    public Result<List<RetailFxLevelVo>>listPage(@RequestBody ParamReq<RetailFxLevelRequest> req) {
        return super.listPage(retailFxLevelService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("分销等级设置-统计")
    public Result<Integer> countPage(@RequestBody ParamReq<RetailFxLevelRequest> req) {
        return super.countPage(retailFxLevelService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("分销等级设置-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<RetailFxLevelRequest> req) {
        return super.page(retailFxLevelService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除分销等级设置")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(retailFxLevelService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除分销等级设置")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(@PathVariable("ids") List<Long> ids) {
        return super.batchDelete(retailFxLevelService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
